$(function(){
	if(localStorage.getItem("$goodsItem")){
		var goodsItem = JSON.parse(localStorage.getItem('$goodsItem'));
		var index = 0;
		var TheTitle = [];
		var TheDiv = [];
		$(goodsItem).each(function(i,obj){
			TheTitle[i] = "<h1 class='mui-title'>"+obj.title+"</h1>";
			TheDiv[i] = "<div class='mui-card'>"+
							"<a class='gotoGoodsDetail' dataid="+obj.id+"   myId="+index+">"+
								"<div class='mui-card-header mui-card-media' style='height:40vw;'>"+
								"<img class='w100' src="+obj.imgSrc+" /></div>"+
								"<div class='mui-card-content'>"+
									"<div class='mui-card-content-inner'>"+
										"<p style='color: #333;' class = 'name'>"+obj.name+"</p>"+
									"</div>"+
								"</div>"+
								"<div class='pattern-list__p'>"+
									"<p class='font-color-pink'>￥<label class = 'price'>"+obj.price+"</label></p>"+
									"<p>库存<label class ='repertory'>"+obj.repertory+"</label></p>"+
								"</div>"+
							"</a>"+
						"</div>";
			index++;			
		});
		
		
		//alert(TheDiv.length);
		//设置标题
		$(".mui-bar").append(TheTitle[0]);
		//将数据放入页面
		for(var n = 0; n < TheDiv.length ;n++){
			$(".Myli").append(TheDiv[n]);
		}
	
		
		
	}else{
		$(".new-pattern")[0].innerHTML = "";
		$(".new-pattern")[0].innerHTML = "<div class='mui-content-padded' style= 'margin-left: 100px; margin-top: 50px; '>"+
				"<div class='mui-card-content'><div class='mui-card-content-inner'>"+
				"很抱歉,暂无数据...</div></div></div>";
	}
	
	$(".gotoGoodsDetail").click(function() {
				// var goodsItem = {};
				let data = JSON.parse(localStorage.getItem('$appData'))
				// goodsItem.name = $(this).children("div").eq(1).children("div").children("p").text();
				// goodsItem.price = $(this).children("div").eq(2).children("p").eq(0).children("label").text();
				// goodsItem.repertory = $(this).children("div").eq(2).children("p").eq(1).children("label").text();
				// goodsItem.imgSrc = "../" + $(this).children("div").eq(0).children("img").attr("src");
				// console.log(this.dataset.id)
				let goodsItem = AppData.getGood(data.data, $(this).attr("dataid"));
				localStorage.setItem("$detail", JSON.stringify(goodsItem));
				window.location.href = "new-personal-details.html";

		});

});






